"""
数据统计页面

显示系统统计信息的页面
"""

import tkinter as tk
from tkinter import ttk
from pathlib import Path
import sys

# 添加项目根目录到路径
project_root = Path(__file__).parent.parent.parent.parent
sys.path.insert(0, str(project_root))

from src.gui.main_app import BasePage


class StatisticsPage(BasePage):
    """数据统计页面"""
    
    def create_page(self):
        """创建页面内容"""
        self.frame = ttk.Frame(self.parent)
        
        # 页面标题
        header_frame = ttk.Frame(self.frame)
        header_frame.pack(fill="x", pady=(0, 20))
        
        title_label = ttk.Label(
            header_frame,
            text="📊 数据统计",
            style='Title.TLabel'
        )
        title_label.pack(side="left")
        
        # 统计卡片区域
        cards_frame = ttk.Frame(self.frame)
        cards_frame.pack(fill="x", pady=(0, 20))
        
        # 创建统计卡片
        self.create_stat_cards(cards_frame)
        
        # 图表区域
        chart_frame = ttk.LabelFrame(self.frame, text="统计图表", padding="20")
        chart_frame.pack(fill="both", expand=True)
        
        chart_info = ttk.Label(
            chart_frame,
            text="📈 图表功能开发中...\n\n将包括：\n• 素材类型分布图\n• 上传趋势图\n• 存储使用情况\n• 处理效率统计",
            justify="center"
        )
        chart_info.pack(expand=True)
    
    def create_stat_cards(self, parent):
        """创建统计卡片"""
        # 统计数据
        stats = [
            ("总素材数", "1,234", "🎬"),
            ("视频素材", "856", "📹"),
            ("图片素材", "298", "🖼️"),
            ("音频素材", "80", "🎵"),
            ("今日上传", "23", "📤"),
            ("存储使用", "2.5GB", "💾")
        ]
        
        for i, (title, value, icon) in enumerate(stats):
            card_frame = ttk.LabelFrame(parent, text=title, padding="15")
            card_frame.grid(row=i//3, column=i%3, padx=10, pady=10, sticky="ew")
            
            icon_label = ttk.Label(card_frame, text=icon, font=('Arial', 24))
            icon_label.pack()
            
            value_label = ttk.Label(card_frame, text=value, font=('Arial', 18, 'bold'))
            value_label.pack()
        
        # 配置网格权重
        for i in range(3):
            parent.grid_columnconfigure(i, weight=1)
